package com.changgou.seckill.dao;

import com.changgou.seckill.pojo.SecKillTime;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface SecKillTimeMapper extends Mapper<SecKillTime> {
    @Update("")
    void updataTime(Integer time_id, Integer statrus);

    @Insert("<script>" +
            "INSERT INTO tb_seckill_time_goods(time_id,goods_id) VALUES" +
            "<foreach collection='goods_ids'  item='goods_id' separator=',' >" +
            " (#{time_id},#{goods_id})" +
            "</foreach>" +
            "</script>")
    void addSeckillGoods(@Param("time_id")Integer time_id,@Param("goods_ids") List<Integer> goods_ids);

    /**
     * 根据timeId删除活动和商品的关联
     * @param id
     */
    @Delete("delete from tb_seckill_time_goods where time_id = #{id}")
    void deleteByTimeId(Long id);
}
